package com.sykj.bsc.wsy.controller;


import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.sykj.bsc.rwl.po.SysUser;
import com.sykj.bsc.wsy.model.Bis_coupon_active;
import com.sykj.bsc.wsy.model.Bis_coupon_record;
import com.sykj.bsc.wsy.service.Bis_coupon_activeService;
import com.sykj.bsc.zjj.bean.Bis_custom_user;

@Controller
@RequestMapping("wsyactive")
public class Bis_coupon_activeHandler {
    @Autowired
	Bis_coupon_activeService service;
	/**
	 * 根据`status`=2查询bis_coupon_active表信息
	 * @param model
	 * @param active
	 * @return
	 */
	@RequestMapping("selectBis_coupon_active")
	public String selectBis_coupon_active(Model model,Bis_coupon_active active,HttpSession session){
		model.addAttribute("activeList", service.selectBis_coupon_active(active));
		List<Bis_custom_user> custom_user=service.selectBis_custom_user();
		session.setAttribute("custom_user", custom_user);
		return "backstage/wsy/Bis_coupon_activeShow";
		
	}
	/**
	 * 查询bis_coupon_record表信息
	 * @param model
	 * @param active
	 * @param session
	 * @return
	 */
	@RequestMapping("selectBis_coupon_record")
	public String selectBis_coupon_record (Map<String,Object> map,Bis_coupon_record record){
		map.put("recordList", service.selectBis_coupon_record(record));
		map.put("active_id", record.getActive_id()+"");
		return "backstage/wsy/Bis_coupon_recordShow";
		
	}
	/**
	 * 根据active_id删除bis_coupon_active表信息
	 * @param model
	 * @param active
	 * @return
	 */
	@RequestMapping("deleteBis_coupon_active")
	public String deleteBis_coupon_active (Model model,Bis_coupon_active active){
		service.deleteBis_coupon_active(active.getActive_id());
		return "redirect:/wsyactive/selectBis_coupon_active";
	}
	/**
	 * 对bis_coupon_active表信息进行添加
	 * @param model
	 * @param active
	 * @param session
	 * @return
	 */
	@RequestMapping("insertBis_coupon_active")
	public String insertBis_coupon_active(Model model,Bis_coupon_active active,HttpSession session,HttpServletRequest request) {
		SysUser user=(SysUser)session.getAttribute("user");
		active.setCreate_user_id(user.getUser_id());
		String active_name=request.getParameter("active_name");
		String mobile=request.getParameter("mobile");
		String beauty_num=request.getParameter("beauty_num");
		String bond_num=request.getParameter("bond_num");
		System.err.println(mobile+"--------------------------------------------"+active_name);
		active.setActive_name(active_name);
		active.setMobile(mobile);
		active.setBeauty_num(Integer.valueOf(beauty_num));
		active.setBond_num(Integer.valueOf(bond_num));
		service.insertBis_coupon_active(active);
		return "redirect:/wsyactive/selectBis_coupon_active";
	}
}
